// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Components/TimelineComponent.h"
#include "MainUI.generated.h"

class UCanvasPanel;
class UTextBlock;
class UButton;
class ASoulKnightPlayerController;

/**
 * 
 */
UCLASS()
class SOULKNIGHT_API UMainUI : public UUserWidget
{
	GENERATED_BODY()
	
public:
	UMainUI(const FObjectInitializer& ObjectInitializer);

	virtual void NativeConstruct() override;
	virtual void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override;

	UFUNCTION()
	void ChangeMenu();
	
	UFUNCTION()
	void ToggleMenu(bool bShowGameOption);
	
	UFUNCTION()
	void OnTwinkleTimelineTick(float Output);

	UFUNCTION()
	void OnTwinkleTimelineEndEvent(float Output);

	UFUNCTION()
	void NewGame();

	UFUNCTION()
	void QuitGame();

	UFUNCTION()
	void CreateOnlineGame();

public:
	// “点击开始”的canvas
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget))
	UCanvasPanel* BeginStartCanvas;

	// 游戏选项的canvas
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget))
	UCanvasPanel* GameOptionCanvas;

	// 切换BeginStartCanvas和GameOptionCanvas
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget))
	UButton* ToggleGameOptionButton;

	// 开始游戏提示文本
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget))
	UTextBlock* BeginStartTip;
	
	// 曲线
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	UCurveFloat* StartUITwinkleCurve;

	// 闪烁的timeline
	FTimeline StartUITwinkleTimeline;

	// 开始新游戏
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget))
	UButton* NewGameButton;

	// 离线游戏
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget))
	UButton* OnlineGameButton;

	// 继续游戏
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget))
	UButton* ContinueGameButton;

	// 退出游戏
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget))
	UButton* QuitGameButton;

	// 切换到游戏选项的动画
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, meta = (BindWidgetAnim))
	UWidgetAnimation* SwitchGameOptionAnim;


private:
	UFUNCTION()
	void OnSwitchGameOptionAnimReverseComplete();
	
private:
	FTimerHandle StartUITwinkleHandle;
	FOnTimelineFloat OnTimelineFloatEvent;
	FOnTimelineEvent OnTimelineFinishedEvent;

	FTimerHandle TimerHandle_OnSwitchGameOptionAnimReverseComplete;

private:
	bool bGameOption;
};
